package com.superview.web.action;

import org.apache.struts.actions.DispatchAction;
import org.springframework.stereotype.Controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


import com.superview.power.CmdFactory;
import com.superview.power.SocketFactory;
import com.superview.reader.Reader;


@Controller("/init")
public class InitAction extends DispatchAction {
	
	public ActionForward loginout(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)  {
		System.out.println("run 1");
		Reader r = new Reader(26000," 各监测人员请注意：本次监测参与人员如下；   大屏播报台：  张三；  一号监测机：  李四；  二号监测机： 王五；  三号监测机：  赵六；    四号监测机：  小王；  监控过程中有答题任务：回答正确可以奖励金币；现在监控开始：请各监测机开始监控；");
		r.read();
		System.out.println("run 2");
		 SocketFactory.request(CmdFactory.CMD_SET_IO_OUT_VALUE, (byte) 0);
			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 1);
			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 2);
			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 3);
			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 4);
//			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 5);
//			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 6);
//			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 7);
//			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 8);
//			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 9);
//			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 10);
//			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 11);
//			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 12);
//			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 13);
//			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 14);
//			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 15);
//			SocketFactory.request(CmdFactory.CMD_SET_SIG_IO_SOME_BIT, (byte) 16);
		return null;
	}
	
	public ActionForward opendoor(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)  {
		System.out.println("run 11");
		Reader r = new Reader(55,12000,"恭喜您：闯关成功！大门已开启，请马上进入！");
		r.read();
		System.out.println("run 22");
		return null;
	}
	
	public ActionForward play(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)  {
		System.out.println("run 11");
		Reader r = new Reader(55,15000,"请您拼出正确的图案，挑战成功，才可以开启大门！");
		r.read();
		System.out.println("run 22");
		return null;
	}

}
